import ursina as ursina

class Floor(ursina.Entity):
    '''
        地板，继承自Entity
    '''
    def __init__(self,position=[0.0,0.0,0.0],\
                 parent="scene",model="cube",scale=1,texture_path="../../resources/textures/plank.jpg"):
        super().__init__(position=ursina.Vec3(position[0],position[1],position[2]),\
                         parent=parent\
                         ,model=model,\
                         scale=scale,\
                         texture=ursina.load_texture(texture_path))

class Brick(ursina.Entity):
    '''
        砖块
    '''
    def __init__(self,position=[0.0,0.0,0.0],parent="scene",model="cube",texture_path="resources/textures/brick.jpg"):
        super().__init__(position=ursina.Vec3(position[0],position[1],position[2]),
                         parent=parent,
                         model=model,
                         texture=ursina.load_texture(texture_path))
class Robot(ursina.Entity):
    '''
        机器人模型
    '''
    def __init__(self):
        pass
class Environment:
    '''
        模拟环境
    '''
    def __init__(self):
        self.floor_List=[]
        self.wall_List=[]
        ursina.EditorCamera()
    def LoadFloor(self,cell_x_Nums=10,\
                  cell_y_Nums=10,cell_Size=1.0,\
                  origin_x=-5,origin_y=-5,origin_z=0,\
                  texture="resources/textures/brick.jpg"):
        '''
            加载地面
        :param cell_x_Nums:
        :param cell_y_Nums:
        :param cell_Size:
        :param origin_x:
        :param origin_y:
        :param origin_z:
        :param texture:
        :return:
        '''
        x_addr=origin_x;y_addr=origin_y;z_addr=origin_z
        for x in range(cell_x_Nums):
            for z in range(cell_y_Nums):
                self.floor_List.append(Floor(position=[x_addr,y_addr,z_addr]))
                z_addr+=cell_Size
            z_addr-=cell_Size*cell_y_Nums
            x_addr+=cell_Size

if __name__=='__main__':
    app = ursina.Ursina(title="ASD", development_mode=False, fullscreen=False, size=(1600.0, 900.0), borderless=False)
    env=Environment()
    boy=ursina.Entity(model="../../resources/3d_models/chimney.STL")
    boy.y=-3
    boy.color=ursina.color.green
    env.LoadFloor()
    app.run()


